package yuxi2;

//模拟用户名密码登录

import java.util.Scanner;

public class StringDemo {
    public static void main(String[] args) {
        String name = "wzl";
        String word = "123";
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入用户名:");
            String a = sc.nextLine();
            System.out.println("请输入密码:");
            String b = sc.nextLine();
            if (a.equals(name) && b.equals(word)) {
                System.out.println("登录成功");
                break;
            } else {
                if (2 - i == 0) {
                    System.out.println("账户锁定，请与管理员联系");
                } else {
                    System.out.println("登录失败，你还有" + (2 - i) + "次登录机会");
                }
            }
        }
    }
}